package com.amiu.shiro;

import org.apache.shiro.cache.Cache;
import org.apache.shiro.cache.CacheException;

public class ShiroSpringCacheManager implements org.apache.shiro.cache.CacheManager{

	private org.springframework.cache.CacheManager springCacheManager;
	
//	public void setSpringCacheManager(
//			org.springframework.cache.CacheManager springCacheManager) {
//		this.springCacheManager = springCacheManager;
//	}

	public org.springframework.cache.CacheManager getSpringCacheManager() {
		return springCacheManager;
	}

	public ShiroSpringCacheManager(org.springframework.cache.CacheManager springCacheManager){
		this.springCacheManager = springCacheManager;
	}
	
	@Override
	public <K, V> Cache<K, V> getCache(String name) throws CacheException {
		org.springframework.cache.Cache cache = 
				springCacheManager.getCache(name);
		return new ShiroSpringCache<K, V>(cache);
	}

}
